package kr.co.choongang;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class EmpInsertDAO implements EmpSelectInterface{
	private String emp_id;
	private String ename;
	private String salary;
	private String depart;
	private String driver;
	private String url;
	private String userid;
	private String passwd;
	private Connection conn;
	private Statement stmt;
	private String sql;
	public EmpInsertDAO() throws ClassNotFoundException {
		driver = "oracle.jdbc.driver.OracleDriver";
		url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
		userid = "kdoing";
		passwd = "dkdlxl";
		Class.forName(driver);
	}
	@Override
	public void setConnection() throws SQLException{
		conn = DriverManager.getConnection(url, userid, passwd);
	}
	@Override
	public void setStatement(EmpSelectDTO dto) throws SQLException{
		stmt = conn.createStatement();		
		sql = "insert into emp(emp_id,ename,salary,depart) values('"+dto.getEmp_id()+"','"+dto.getEname()+"',"+dto.getSalary()+",'"+dto.getDepart()+"')";
	}
	@Override
	public int executeQuery() throws SQLException{
		int n=stmt.executeUpdate(sql);
		return n; 
	}
	@Override
	public ResultSet executeQuerySelect() throws SQLException {
		ResultSet rs=null;
		return rs;
	}
	@Override
	public EmpSelectDTO setSelectResult() throws SQLException {
		EmpSelectDTO empSelectDTO=null;
		return empSelectDTO;
	}
	
}
